<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');


/**
 * This class is for online shop order process - payment.
 * params order step
 * This is the children of controller.
 * PHP5 CMS Typolight
 * Copyright is 34n.sam@gmail.com
 */
 
 /**
 * Start page
 */
session_start();

class getCurrency extends Controller
{
	public function run(){
		global $objPage;
		
		$this->import('Database');
		$obj_currency = $this->Database->prepare("SELECT * FROM `tl_currency`")
										->execute();
		$str_html = '<script type="text/javascript">
			function change_currency(obj,iso_code){
				$.cookie("DAFT_CURRENCY",iso_code);
				window.location.href = location.href;
				return false;
			}';
		
		if (strpos($objPage->alias,"home") !== false){
			$str_html .= 'function currency_image_disappear(){
				jQuery("#disappear_currency_img").hide();
			}
			jQuery(function(){
				setTimeout("currency_image_disappear()",5000);
			});';
		}
			
		$str_html .= '</script>
		<div class="box_currency"><ul id="menu">';
		while ($obj_currency->next())
		{
			$str_html .= '<li class="'.strtolower($obj_currency->iso_code).'"><a href="javascript:void(0);" onclick="return change_currency(this,\''.strtolower($obj_currency->iso_code).'\');" title="Choose your preferred currency"><img style="border:none;" src="images/currency/'.strtolower($obj_currency->iso_code).'.jpg"></a>
							 <ul class="sub_menu_2" style="display: none;">
								 <li>&nbsp;</li>
						   </ul>
						 </li>';
		}
		$str_html .= '</ul>';
		
		if (strpos($objPage->alias,"home") !== false){
			$str_html .= '<div id="disappear_currency_img" class="currency_image"><img src="images/choose_currency.png" alt="Choose your preferred currency" /></div>';
		}
		$str_html .= '</div>';
		echo $str_html;
	}
}

$getCurrency = new getCurrency();
$getCurrency->run();